<script type="text/javascript">
dojo.require('dijit.Dialog');
//dojo.require('dojo.string');
dojo.require('dojox.dtl');
dojo.require('dojox.dtl.Context');

var dialogBox = new dijit.Dialog({
    title: "Detalles da entrada",
    style: "width: 760px"
});

function showDetails(data) {    
    /*var template = '<table><tr><td>Id</td><td>${id}</td></tr><tr><td>Nome</td><td>${name}</td></tr><tr><td>Valor</td><td>${value}</td></tr><tr><td>Paxina</td><td>${page}</td></tr><tr><td>IP</td><td>${ip}</td></tr><tr><td>Impacto</td><td>${impact}</td></tr><tr><td>Orixe</td><td>${origin}</td></tr><tr><td>Data</td><td>${created}</td></tr></table>';
    
    dialogBox.attr("content", dojo.string.substitute(template, data));*/
    
    var template = new dojox.dtl.Template('<table><tr><td>Id</td><td>{{ id }}</td></tr><tr><td>Nome</td><td>{{ name }}</td></tr><tr><td>Valor</td><td>{{ value }}</td></tr><tr><td>Páxina</td><td>{{ page }}</td></tr><tr><td>IP</td><td>{{ ip }}</td></tr><tr><td>Impacto</td><td>{{ impact }}</td></tr><tr><td>Orixe</td><td>{{ origin }}</td></tr><tr><td>Data</td><td>{{ created }}</td></tr></table>');
    var context = new dojox.dtl.Context(data);
    console.log(template.render(context));
    
    dialogBox.attr("content", template.render(context));
    dialogBox.show();
}
</script>

<?php if(count($this->intrusions)>0): ?>
    <table>
    <thead>
        <tr>
            <td>Nome</td>
            <td>Impacto</td>
            <td colspan="2">&nbsp;</td>
        </tr>
    </thead>
    <tbody>
    <?php foreach($this->intrusions as $entry): ?>
    <tr>
        <td><?php echo $entry->id . '# ' . $this->escape($entry->name) ?></td>
        <td><?php echo $this->escape($entry->impact) ?></td>
        
        <td class="button">
            <a href="#details" onclick="showDetails(<?php echo $this->jsonEncodeTableRow($entry)?>)">
                <img src="<?php echo $this->baseUrl() ?>/images/mini/preview.png" border="0" alt="" /></a>
        </td>        
        <td class="button last">
            <a href="<?php echo $this->url(array('module' => 'admin',
                                                 'controller' => 'ids',
                                                 'action' => 'delete',
                                                 'id' => $entry->id)) ?>">
                <img src="<?php echo $this->baseUrl() ?>/images/mini/delete.png" border="0" alt="" /></a>
        </td>
    </tr>
    <?php endforeach; ?>
    </tbody>
    </table>
    
    <?php echo $this->paginationControl($this->intrusions,
                             'Sliding', 'pagination.phtml'); ?>

<?php else: ?>    
    <h2>Non se rexistraron intrusións no sistema.</h2>
<?php endif; ?>